﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AverageWaterlevel.aspx.cs" Inherits="GroundWater.analysis.AverageWaterlevel" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server"><ajaxToolkit:ToolkitScriptManager runat="server" ID="sm"  />
    <div class="region" style="width: 96%; font-size:9pt;">
        <table style="width: 100%;">
            <tr>
                <td>水井:</td><td><asp:DropDownList ID="drpWell" runat="server" 
                DataSourceID="odsWells" DataTextField="Name" DataValueField="Code"   
                EnableViewState="false" OnSelectedIndexChanged="drpWell_SelectedIndexChanged" 
                AutoPostBack="true" ondatabound="drpWell_DataBound" ></asp:DropDownList></td>
                <td>日期从:</td><td><asp:TextBox runat="server"  id="txtStartDate"   />&nbsp;<img onclick="WdatePicker({el:$dp.$('txtStartDate')})" src="../js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle" /></td>
                <td>到:</td><td><asp:TextBox runat="server"  id="txtEndDate"  />&nbsp;<img onclick="WdatePicker({el:$dp.$('txtEndDate')})" src="../js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle" /></td>
                
            </tr>
            <tr>
                <td>平均水位:</td><td><span id="waterLevel" class="warning" style="font-size:12pt;"></span></td>
                <td>平均埋深:</td><td><span id="altitude" class="warning" style="font-size:12pt;"></span></td>
                <td colspan="2"><asp:Button ID="btnAnalysis" runat="server" Text="统计"  onclick="btnAnalysis_Click" /></td>
            </tr>
        </table>
    </div>
    
<asp:ObjectDataSource ID="odsWells" runat="server" SelectMethod="GetAllWithCode" TypeName="GroundWater.BusinessActions.Well" >
    <%--<SelectParameters>
        <asp:Parameter Name="isStoredProc" Type="Boolean" DefaultValue="False" />
        <asp:Parameter Name="enableCache" Type="Boolean" DefaultValue="True" />
    </SelectParameters>--%>
</asp:ObjectDataSource>

 <asp:ObjectDataSource id="odsMonitoring" runat="server" EnablePaging="True" 
     TypeName="GroundWater.BusinessActions.Monitoring" 
     SelectMethod="FetchPaged" SelectCountMethod="FetchRowCount"
     SortParameterName="sortExpression" >
    <SelectParameters>
        <asp:ControlParameter ControlID="drpWell" PropertyName="SelectedValue" Name="wellCode" />
        <asp:ControlParameter ControlID="txtStartDate" PropertyName="Text" Name="startDate" />
        <asp:ControlParameter ControlID="txtEndDate" PropertyName="Text" Name="endDate" />
</SelectParameters>
</asp:ObjectDataSource>

    <div style="width:100%; margin-top:10px;">
        <p style="font-weight:bold; font-family:Tahoma; margin-bottom:8px; "></p>
        <div class="grid">
            <div class="rounded">
                <div class="top-outer"><div class="top-inner"><div class="top">
                    <h2>水位数据 </h2>
                </div></div></div>
                <div class="mid-outer"><div class="mid-inner"><div class="mid">     
                
                    <!-- Content Goes Here! -->
                    <asp:UpdatePanel ID="updPanel" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:GridView 
                                ID="gvMonitoring" runat="server" DataSourceID="odsMonitoring" 
                                SkinID="PagingGridView" DataKeyNames="WellCode,MonitorTime"
                                OnRowDataBound="RowDataBound" >
                                <Columns>
                                    <asp:BoundField  HeaderText="水井名称" DataField="WellName" SortExpression="WSWLNM" 
                                        HeaderStyle-CssClass="first" ItemStyle-CssClass="first" >
                                    <HeaderStyle CssClass="first" />
                                    <ItemStyle CssClass="first" />
                                    </asp:BoundField>
                                    <asp:BoundField  HeaderText="检测时间" DataField="MonitorTime" DataFormatString="{0:yyyy-MM-dd HH:mm}" HtmlEncode="false"  SortExpression="MNTM"  />
                                    <asp:BoundField  HeaderText="水位" DataField="Waterlevel"  DataFormatString="{0:N2}"   SortExpression="Z" />
                                    
                                   
                                    <asp:BoundField  HeaderText="埋深" DataField="Altitude" DataFormatString="{0:N2}" SortExpression="Altitude"  />
                                    <asp:BoundField  HeaderText="卡号" DataField="SIMCard"     SortExpression="COMMNO"  />
                                    <asp:BoundField  HeaderText="设备地址" DataField="BTUAddress"    SortExpression="CONTROLLERID"   />
                                    <asp:BoundField  HeaderText="剖面" DataField="SectionPlane"   SortExpression="NT"  />
                                </Columns>
                            </asp:GridView>   
                        </ContentTemplate>
                        <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnAnalysis" />
                        <asp:AsyncPostBackTrigger ControlID="drpWell" EventName="SelectedIndexChanged" />
                        </Triggers>
                    </asp:UpdatePanel>                     
    
                </div></div></div>
            <div class="bottom-outer"><div class="bottom-inner">
            <div class="bottom"></div></div></div>                   
        </div>      
        </div>
    </div>


<asp:updateprogress id="updateProgress" runat="server" DynamicLayout="true" DisplayAfter="200">
    <progresstemplate>
        <div id="progressBackgroundFilter"></div>
        <div id="processMessage">正在处理数据，请稍等...<br /><br /><img alt="Loading" src="../images/loading_16.gif" /></div>
    </progresstemplate>
</asp:updateprogress>


<script type="text/javascript">
//<![CDATA[
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_pageLoading(pageLoadingHandler);
    function pageLoadingHandler(sender, args) {
        // sender:Sys.WebForms.PageRequestManager
        // args : Sys.WebForms.PageLoadingEventArgs
        var dataItems = args.get_dataItems();
//        var panelsDeleting = args.get_panelsDeleting();
//        var panelsUpdating = args.get_panelsUpdating();
        if (dataItems['btnAnalysis'] && dataItems['btnAnalysis'].length > 0) {
            var s = dataItems['btnAnalysis'].split('|');
            $get("waterLevel").innerText = s[0];
            $get("altitude").innerText = typeof (s[1]) !== "undefined" ? s[1] : "未设置水井的地面高程，无法计算埋深";
        }
        else {
            $get("waterLevel").innerText = "";
            $get("altitude").innerText = "";
        }
    }
//]]>
</script>
    </form>
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
</body>
</html>
